{{define "content"}}
{{template "page_title" .}}
<div id="main" class="row" data-mod="agent">
    <div class="col-12">
        <form class="mb-3">
            <div class="row">
                <div class="col-xl-6">
                    {{include "partials/input/alias"}}
                </div>
                <div class="col-xl-6">
                    {{include "partials/select/status"}}
                </div>
                <div class="col btn-list">
                    <button action="submit" type="button" class="btn btn-primary">
                        {{include "partials/svg/search"}}
                        查询
                    </button>
                    <button action="list" type="button" class="btn btn-info">
                        {{include "partials/svg/reset"}}
                        重置
                    </button>
                </div>
            </div>
        </form>
        <div class="card">
            <div class="table-responsive">
                <table class="table table-hover table-outline table-vcenter text-nowrap card-table">
                    <thead>
                        <tr>
                            <th style="width: 5%"><span>ID</span></th>
                            <th style="width: 10%"><span>别名</span></th>
                            <th style="width: 15%"><span>地址</span></th>
                            <th style="width: 10%"><span>状态</span></th>
                            <th style="width: 60%"></th>
                        </tr>
                    </thead>
                    <tbody>
                        {{- range .List}}
                        <tr>
                            <td>{{.ID}}</td>
                            <td>{{.Alias}}</td>
                            <td>{{.IP}}:{{.Port}}</td>
                            <td>
                                {{if eq .Status 0}}
                                <span class="badge bg-gray">offline</span>
                                {{else if eq .Status 1}}
                                <span class="badge bg-green">online</span>
                                {{else if eq .Status -1}}
                                <span class="badge bg-red">forbidden</span>
                                {{end}}
                            </td>
                            <td>
                                <div class="cmd-info btn-list" data-bind="{{.ID}}">
                                    {{if eq $.Role "Administrator"}}
                                    <button action="edit" title="编辑" class="btn btn-sm btn-secondary ml-auto">
                                        {{include "partials/svg/edit"}}
                                        编辑
                                    </button>
                                    {{if ne .Status -1}}
                                    <button action="forbidden" class="btn btn-danger btn-sm">
                                        {{include "partials/svg/forbidden"}}
                                        禁用
                                    </button>
                                    {{end}}
                                    <button url="/monitor/agent?id={{.ID}}" action="jump" class="btn btn-sm btn-info">
                                        {{include "partials/svg/monitor"}}
                                        运行状态
                                    </button>
                                    <button url="/app/list?agent_id={{.ID}}" action="jump" class="btn btn-sm btn-info">
                                        {{include "partials/svg/app"}}
                                        应用
                                    </button>
                                    <button url="/job/list?agent_id={{.ID}}" title="计划任务列表" class="btn btn-sm btn-info">
                                        {{include "partials/svg/job"}}
                                        计划任务
                                    </button>
                                    <button url="/timing/list?agent_id={{.ID}}" title="定时任务列表" class="btn btn-sm btn-info">
                                        {{include "partials/svg/timing"}}
                                        定时任务
                                    </button>
                                    {{end}}
                                </div>
                            </td>
                        </tr>
                        {{- end}}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<div class="d-flex">
    {{.Pagination | unescaped}}
</div>
{{end}}
{{define "script"}}
<script type="text/javascript">
    $(document).ready(function () {
        $('#status').selectize({});
        Asgard.init("#main", "agent");
    });
</script>
{{end}}